//
//  KLMUserDefault.swift
//  KLM_GN
//
//  Created by Nic on 2025/2/19.
//

import UIKit

enum OperKey: Int {
    case token = 0
    case username
    case password
    
    case SSID
    case WIFIPassword
    
    case KLMPhoneKey
    case KLMPasswordKey
    
    case useGuard
    
    case userGuide
    
    case SigalLimit
    
    case currentSelectedHomeId // 当前切换/选中的家庭ID
}


class KLMUserDefault: NSObject {

    static func getValue(for key: OperKey)  -> Any? {
        switch key {
        case .username:
            return KLMGetUserDefault("username")
        case .password:
            return KLMGetUserDefault("password")
        case .SSID:
            return KLMGetUserDefault("SSID")
        case .WIFIPassword:
            return KLMGetUserDefault("WIFIPassword")
        case .KLMPhoneKey:
            return KLMGetUserDefault("KLMPhoneKey")
        case .KLMPasswordKey:
            return KLMGetUserDefault("KLMPasswordKey")
        case .useGuard:
            return KLMGetUserDefault("useGuard")
        case .userGuide:
            return KLMGetUserDefault("userGuide")
        case .SigalLimit:
            return KLMGetUserDefault("SigalLimit")
        case .currentSelectedHomeId:
            return KLMGetUserDefault("currentSelectedHomeId")
        default:
            return KLMGetUserDefault("token")
        }
    }
    
    static func setValue(for key: OperKey, with value: Any?) {
        switch key {
        case .username:
            KLMSetUserDefault("username", value)
        case .password:
            KLMSetUserDefault("password", value)
        case .SSID:
            KLMSetUserDefault("SSID", value)
        case .WIFIPassword:
            KLMSetUserDefault("WIFIPassword", value)
        case .KLMPhoneKey:
            KLMSetUserDefault("KLMPhoneKey", value)
        case .KLMPasswordKey:
            KLMSetUserDefault("KLMPasswordKey", value)
        case .useGuard:
            KLMSetUserDefault("useGuard", value)
        case .userGuide:
            KLMSetUserDefault("userGuide", value)
        case .SigalLimit:
            KLMSetUserDefault("SigalLimit", value)
        case .currentSelectedHomeId:
            KLMSetUserDefault("currentSelectedHomeId", value)
        default:
            KLMSetUserDefault("token", value)
        }
    }
}
